5.32

 

题目

Prove that the following two languages are undecidable.

b. PREFIX-FREECFG = {GG is a CFG where L(G) is prefix-free}.


思路

点击展开

对 5.21 略作修改,让骨牌匹配等价于找到 CFG 的一个字符串是另一个字符串的前缀


解答

点击展开

对 5.21 的 Hint 修改,增加 a0,调整 ai 的位置,结果如下:

Given an instance

P={[t1b1],[t2b2],,[tkbk]}

of the Post Correspondence Problem, construct a CFG G with the rules

STBa0Ta1Tt1akTtka1#t1ak#tkBa1Bb1akBbka1#b1ak#bk

where a0,a1,,ak,# are new terminal symbols.

如果存在骨牌匹配,即 b1b2bk=t1t2tk,那么 a1a2ak#tkt2t1a1a2ak#bkb2b1a0 的前缀,且两者均在 L(G)

反之,如果存在 L(G) 中的相异字符串 M 是 N 的前缀,a1a2ak# 部分必须相同,这代表 M 和 N 分别由 T 和 B 生成,否则 M 和 N 相同。进而,b1b2bk=t1t2tk